package com.gisocn.onemap.ui.popupwindow;

import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gisocn.onemap.interfaces.OnItemClickChildListener;
import com.gisocn.onemap.model.DynamicInfo;
import com.gisocn.onemap.model.LayerQueryInfo;
import com.gisocn.onemap.sgzx.R;
import com.gisocn.onemap.ui.adapter.DynamicQueryAdapter;
import com.gisocn.onemap.ui.adapter.QueryLandsAdapter;
import com.gisocn.onemap.utils.L;
import java.util.ArrayList;
import java.util.Iterator;

/* loaded from: classes2.dex */
public class LandInfosPopWindow extends PopupWindow {
    private QueryLandsAdapter adapter;
    private Context context;
    private DynamicQueryAdapter dynamicAdapter;
    private ArrayList<DynamicInfo> dynamicList;
    private int height;
    boolean isCollection;
    private ArrayList<LayerQueryInfo> list;
    RecyclerView recycle_land_info;
    RecyclerView recycle_land_info_online;
    TextView tvCount;
    private int width;
    private OnItemClickChildListener onItemClickListener = null;
    private OnItemClickChildListener onItemClickDynamicListener = null;

    public void getDeatilInfo() {
    }

    public LandInfosPopWindow(ArrayList<LayerQueryInfo> arrayList, Context context, int i, int i2) {
        this.context = context;
        this.width = i;
        this.height = i2;
        this.list = arrayList;
        initView();
    }

    public LandInfosPopWindow(ArrayList<LayerQueryInfo> arrayList, ArrayList<DynamicInfo> arrayList2, Context context, int i, int i2) {
        this.context = context;
        this.width = i;
        this.height = i2;
        this.list = arrayList;
        this.dynamicList = arrayList2;
        initView();
    }

    public void setOnItemClickListener(OnItemClickChildListener onItemClickChildListener) {
        this.onItemClickListener = onItemClickChildListener;
    }

    public void setOnItemClickDynamicListener(OnItemClickChildListener onItemClickChildListener) {
        this.onItemClickDynamicListener = onItemClickChildListener;
    }

    private void initView() {
        this.isCollection = false;
        final View inflate = View.inflate(this.context, R.layout.popup_query_land, null);
        setContentView(inflate);
        setWidth(this.width);
        setHeight(this.height);
        setFocusable(false);
        setOutsideTouchable(false);
        setBackgroundDrawable(new BitmapDrawable());
        ((TextView) inflate.findViewById(R.id.tv_title)).setTypeface(Typeface.defaultFromStyle(1));
        TextView textView = (TextView) inflate.findViewById(R.id.tv_count);
        this.tvCount = textView;
        textView.setText(totalCount() + "条记录");
        this.recycle_land_info = (RecyclerView) inflate.findViewById(R.id.recycle_land_info);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.context);
        linearLayoutManager.setOrientation(1);
        this.recycle_land_info_online = (RecyclerView) inflate.findViewById(R.id.recycle_land_info_online);
        LinearLayoutManager linearLayoutManager2 = new LinearLayoutManager(this.context);
        linearLayoutManager2.setOrientation(1);
        this.adapter = new QueryLandsAdapter(this.list, this.context);
        this.dynamicAdapter = new DynamicQueryAdapter(this.dynamicList, this.context);
        this.recycle_land_info.setLayoutManager(linearLayoutManager);
        this.recycle_land_info.setAdapter(this.adapter);
        this.recycle_land_info_online.setLayoutManager(linearLayoutManager2);
        this.recycle_land_info_online.setAdapter(this.dynamicAdapter);
        this.adapter.setOnItemClickListener(new OnItemClickChildListener() { // from class: com.gisocn.onemap.ui.popupwindow.LandInfosPopWindow.1
            @Override // com.gisocn.onemap.interfaces.OnItemClickChildListener
            public void onItemClick(View view, int i, int i2) {
                if (LandInfosPopWindow.this.onItemClickListener != null) {
                    LandInfosPopWindow.this.onItemClickListener.onItemClick(inflate, i, i2);
                }
            }
        });
        this.dynamicAdapter.setOnItemClickDynamicListener(new OnItemClickChildListener() { // from class: com.gisocn.onemap.ui.popupwindow.LandInfosPopWindow.2
            @Override // com.gisocn.onemap.interfaces.OnItemClickChildListener
            public void onItemClick(View view, int i, int i2) {
                if (LandInfosPopWindow.this.onItemClickDynamicListener != null) {
                    LandInfosPopWindow.this.onItemClickDynamicListener.onItemClick(inflate, i, i2);
                }
            }
        });
        ((TextView) inflate.findViewById(R.id.tv_close)).setOnClickListener(new View.OnClickListener() { // from class: com.gisocn.onemap.ui.popupwindow.LandInfosPopWindow.3
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                LandInfosPopWindow.this.dismiss();
            }
        });
    }

    public void updata(ArrayList<LayerQueryInfo> arrayList, ArrayList<DynamicInfo> arrayList2) {
        if (arrayList != null) {
            this.list.clear();
            this.list.addAll(arrayList);
            this.adapter.notifyDataSetChanged();
        }
        this.recycle_land_info.setVisibility(this.list.size() == 0 ? 8 : 0);
        if (arrayList2 != null) {
            this.dynamicList.clear();
            this.dynamicList.addAll(arrayList2);
            this.dynamicAdapter.notifyDataSetChanged();
        }
        this.recycle_land_info_online.setVisibility(this.dynamicList.size() != 0 ? 0 : 8);
        TextView textView = this.tvCount;
        textView.setText(totalCount() + "条记录");
    }

    public int totalCount() {
        Iterator<DynamicInfo> it = this.dynamicList.iterator();
        int i = 0;
        while (it.hasNext()) {
            DynamicInfo next = it.next();
            L.e("totalCount" + next.getGetGraphics().size());
            i += next.getGetGraphics().size();
        }
        L.e("totalCount_在线" + this.dynamicList.size());
        return i;
    }
}
